import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName: StreamDemo
 * @Author: liugui
 * @Date: 2021-07-26 14:53
 **/
public class StreamDemo {
    public static void main(String[] args) {
        User u1 = new User(1,"a",23);
        User u2 = new User(2,"b",22);
        User u3 = new User(3,"c",21);
        User u4 = new User(4,"d",25);
        User u5 = new User(5,"e",33);

        List<User> userList = Arrays.asList(u1,u2,u3,u4,u5);
        userList.stream()
                .filter(user -> {return user.getId()%2==0;})
                .filter(user -> {return user.getAge()>23;})
                .map(user -> {return user.getName().toUpperCase();})
                .sorted((user1,user2)->{return user2.compareTo(user1);})
                .limit(1)
                .forEach(System.out::println);
    }
}

class User{
    private int id;
    private String name;
    private int age;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public User(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public User() {
    }
}
